//
//  ChecksEndViewController.m
//  NewApp
//
//  Created by xueyan liu on 6/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ChecksEndViewController.h"
#import "AppDelegate.h"
#import "ShoppingCarViewController.h"
#import "UINavigationBar+Additions.h"

@interface ChecksEndViewController ()

@end

@implementation ChecksEndViewController
@synthesize titleText;
@synthesize msg;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setFrame:CGRectMake(0, 26, 320, 480)];
    self.titleLabel.text = titleText;
    lblMessage.numberOfLines = 0;
    [lblMessage setText:msg];
    lblMessage.textColor = [UIColor whiteColor];
    [self.view setBackgroundColor:[UIColor clearColor]];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

-(IBAction)goBack:(id)sender{

    [self.navigationController popToRootViewControllerAnimated:NO];
    //[self.parentViewController.parentViewController release];
    NSMutableArray *tempArray = [[AppDelegate theAppDelegate].tabBarController.viewControllers mutableCopy];
    [tempArray removeObjectAtIndex:2];
    
    ShoppingCarViewController *shoppingCarViewController = [[ShoppingCarViewController alloc] init];
    shoppingCarViewController.title = @"返回";
    shoppingCarViewController.tabBarItem.title = @"購物車";
    shoppingCarViewController.tabBarItem.image = [UIImage imageNamed:@"shopping_trolley_icon.png"];
    
    UINavigationController *navitaionShoppingCar = [[UINavigationController alloc] initWithRootViewController:shoppingCarViewController];
    [navitaionShoppingCar.navigationBar setBkImage:[UIImage imageNamed:@"top_logo.png"]];
    [shoppingCarViewController release];
    
    [tempArray insertObject:navitaionShoppingCar atIndex:2];
    
    [AppDelegate theAppDelegate].tabBarController.viewControllers = tempArray;
    [AppDelegate theAppDelegate].tabBarController.selectedIndex = TABBAR_ITEM_HOME;

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
